
MAKEFLAGS="-s" 

What= $(shell basename $(PWD))
Profile= $(Tmp)/awkprof.out
Vars=    $(Tmp)/awkvars.out
Time=    "%U sec(s) user %S system sec(s) "
Seed=    $(shell bash bin/rand)
Dirs=    var $(Tmp) lib bin $(Opt)/tmp $(Opt)/lib

#running awk
Awk=     $(Gawk) --dump-variables=$(Vars) --profile=$(Profile)
AwkPath= $(AWKPATH):lib:$(Opt)/lib

#building awk
Opt=     $(HOME)/opt
GawkTar= http://ftp.gnu.org/gnu/gawk/$(GawkVer).tar.xz
GawkOpt= $(Opt)/gawk
Gawk=    $(GawkOpt)/bin/pgawk
Pandoc=  $(HOME)/.cabal/bin/pandoc 
$(Gawk): ; bash bin/getgawk $(GawkTar) $(GawkVer)  $(Tmp) $(GawkOpt)
$(Pandoc):; sudo bash bin/getpandoc

reset: dirs $(Gawk) $(Pandoc)

dirs: 
	@-$(foreach d,$(Dirs),if [ ! -d $d ]; then mkdir -p $d; fi;)

run:
	echo "\n===[ $(What) : $(main) :: $(data) ]==========================\n"
	AWKPATH="$(AwkPath)" \
            time -f$(Time)  \
              $(Awk) -f $(main).awk -v $(Args) data/$(data).csv
debug:
	@sort $(Vars) | egrep  '^[a-z_]'